package com.xqb.listen.service

import android.app.Service
import android.content.Intent
import com.xqb.listen.manager.ForegroundServiceManager
import com.xqb.listen.manager.MediaPlayManager


/**
 * @author Ling
 * @date :2025/1/23 15:41
 */
class MusicForegroundService : Service() {
    override fun onBind(intent: Intent?) = null

    override fun onCreate() {
        super.onCreate()
        MediaPlayManager.singleInstance.initMediaPlayer(this)
    }

    override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
        // 启动前台服务
        startForeground(1, ForegroundServiceManager.createNotification(this , intent))
        return START_STICKY
    }

    override fun onDestroy() {
        MediaPlayManager.singleInstance.destroyPlayer()
        super.onDestroy()
    }
}